<template>
  <div class="condition">
    <template v-for="(item, index) in props.conditionExpression" :key="index">
      <div class="box">
        <div class="left">
          且 (and)
        </div>
        <div class="item">
          <template v-for="(v, i) in item.formDataList" :key="i">
            <div class="right-item">
              <span>{{ v.variableName }}</span>
              <span>{{ v.symbolName }}</span>
              <span>
                <div v-if="v.parameterNameList?.length !== 0">
                  <template v-for="(r, j) in v.parameterNameList" :key="j">
                    {{ v.parameterNameList?.length - 1 === j ? r : r + '、' }}
                  </template>
                </div>
                <div v-else>
                  <template v-for="(r, j) in v.parameterCodeList" :key="j">{{ r }}</template>
                </div>
              </span>
            </div>
          </template>
        </div>
      </div>
      <el-divider v-if="index !== props.conditionExpression?.length - 1">
        或(or)
      </el-divider>
    </template>
  </div>
</template>

<script setup>
import { useI18n } from 'vue-i18n'
const { t } = useI18n() // 中英文
const props = defineProps({
  conditionExpression: {
    type: Array,
    default: () => []
  }
})
</script>

<style lang="scss" scoped>
.condition {
  max-height: 200px;
  overflow-x: hidden;
  overflow-y: auto;
  margin-right: -9px;
  .box {
    width: 100%;
    display: flex;
    .left {
      width: 78px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      &::after {
        content: '';
        width: 16px;
        height: 1px;
        margin-left: 8px;
        background: #d6d6d6;
      }
    }
    .item {
      display: flex;
      flex-direction: column;
      width: calc(100% - 117px);
      border-radius: 4px;
      border: 1px solid #d6d6d6;
      padding: 12px;
      .right-item {
        display: flex;
        align-items: center;
        padding: 4px 8px;
        border-radius: 2px;
        background: #fafafa;
        margin-bottom: 12px;
        &:last-child {
          margin-bottom: 0;
        }
        span {
          &:nth-child(1) {
            width: 30%;
          }
          &:nth-child(2) {
            width: 20%;
          }
          &:nth-child(3) {
            width: 50%;
          }
          div {
            width: 100%;
          }
        }
      }
    }
  }
  &::-webkit-scrollbar {
    height: 5px;
    width: 5px;
  }
  &::-webkit-scrollbar-corner {
    background: #204754;
  }
  &::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
  }
  &::-webkit-scrollbar-track {
    background: #fff;
    border-radius: 2px;
  }
}
</style>
